package edu.sctu.xialei.june.day20150628two_test;

import edu.sctu.xialei.june.day20150628two_test.IO.IOStreamUtil;
import edu.sctu.xialei.june.day20150628two_test.good.GoodsPriceCounter;
import edu.sctu.xialei.june.day20150628two_test.good.Printer;
import edu.sctu.xialei.june.day20150628two_test.http.UrlMethods;
import edu.sctu.xialei.june.day20150628two_test.http.UrlPath;
import edu.sctu.xialei.june.day20150628two_test.json.AppBean;
import edu.sctu.xialei.june.day20150628two_test.json.JsonToParse;
import edu.sctu.xialei.june.day20150628two_test.thread.SleepWhile;
import java.io.IOException;

/**
 * Created by Administrator on 2015/6/28.
 */
public class Call {

    /**
     *
     * @param args
     */

    public static void main(String[] args) {

        new SleepWhile().run();

        String jsonString = null;
        try {
            jsonString = new UrlMethods().urlGET(new UrlPath().setPath("api.ii.com.cn/goods/apprec?page=1&size=10"));
        } catch (IOException e) {
            e.printStackTrace();
        }

        IOStreamUtil ioStreamUtil = new IOStreamUtil();

        ioStreamUtil.saveFile(jsonString, "D:Json/Json.txt");

        String file = null;
        file = ioStreamUtil.getOutFile("D:Json/Json.txt");

        AppBean appBean = new JsonToParse().parse(file);

        ioStreamUtil.saveFileBySER(appBean,"D:Json/Appbean.txt");

        AppBean appBeanFile = ioStreamUtil.getOutFileBySER("D:Json/Appbean.txt");

        new Printer().printNum(new GoodsPriceCounter().countPrice(appBeanFile));

    }
}
